ENMTools

This package implements various tests, visualizations, and metrics for use with environmental niche models (ENMs) and species distribution models (SDMs).


Installation

At present, ENMTools is downloadable from https://github.com/danlwarren/ENMTools. There are multiple ways to download it. The easiest is to use devtools and install from GitHub.

Installing from GitHub using devtools

Run the following code from your R console:

install.packages("devtools")
library(devtools)
install_github("danlwarren/ENMTools")
library(ENMTools)

Install from zip file

A zipped version of the package is available at https://github.com/danlwarren/ENMTools/archive/master.zip. To install from the zip file, download a copy of it to your system. Once it’s finished downloading, type the following (where PATH is the path to the zip file):

install.packages("devtools")
library(devtools)
install_local("PATH")
library(ENMTools)

Interacting with ENMTools

Creating enmtools.species objects

First we’re going to load in some environmental data.

env.files <- list.files(path = "test/testdata/", pattern = "pc", full.names = TRUE)
env <- stack(env.files)
names(env) <- c("layer.1", "layer.2", "layer.3", "layer.4")
env <- setMinMax(env)

ENMTools is primarily designed to examine patterns of similarity and difference between ENMs for different species. In order to simplify interactions with the functions in ENMTools, you need to put your data for each of your species into an enmtools.species object. You can create and view an empty enmtools.species object just by typing:

ahli <- enmtools.species()
ahli
## 
## 
## Range raster not defined.
## 
## Presence points not defined.
## 
## Background points not defined.
## 
## Species name not defined.

You can add data to this object manually:

names(ahli)
## [1] "range"             "presence.points"   "background.points"
## [4] "models"            "species.name"
ahli$species.name <- "ahli"
ahli$presence.points <- read.csv("test/testdata/ahli.csv")[,3:4]
ahli$range <- background.raster.buffer(ahli$presence.points, 50000, mask = env)
ahli$background.points <- background.points.buffer(points = ahli$presence.points,
                                                   radius = 20000, n = 1000, mask = env[[1]])

ahli
## 
## 
## Range raster: 
## class       : RasterLayer 
## dimensions  : 418, 1535, 641630  (nrow, ncol, ncell)
## resolution  : 0.008333333, 0.008333333  (x, y)
## extent      : -86.90809, -74.11642, 19.80837, 23.2917  (xmin, xmax, ymin, ymax)
## coord. ref. : NA 
## data source : in memory
## names       : layer.1 
## values      : 1, 1  (min, max)
## 
## 
## 
## Presence points (first ten only): 
## 
##  Longitude   Latitude
## ----------  ---------
##   -80.0106    21.8744
##   -79.9086    21.8095
##   -79.8065    21.7631
##   -79.8251    21.8095
##   -79.8807    21.8374
##   -79.9550    21.8374
##   -80.3446    22.0136
##   -80.2983    21.9951
##   -80.1776    21.9023
##   -80.1591    21.9673
## 
## 
## Background points (first ten only): 
## 
##  Longitude   Latitude
## ----------  ---------
##  -79.94559   21.92920
##  -80.22059   22.03754
##  -79.86226   22.07920
##  -79.94559   21.88754
##  -79.70392   21.77920
##  -80.07892   22.03754
##  -79.92892   22.12920
##  -79.89559   21.79587
##  -79.94559   22.11254
##  -80.16226   22.10420
## 
## 
## Species name:  ahli

Or you can add bits of it when the object is created:

allogus <- enmtools.species(species.name = "allogus", 
                            presence.points = read.csv("test/testdata/allogus.csv")[,3:4])

allogus$range <- background.raster.buffer(allogus$presence.points, 50000, mask = env)
allogus$background.points <- background.points.buffer(points = allogus$presence.points,
                                                      radius = 20000, n = 1000, mask = env[[1]])

allogus
## 
## 
## Range raster: 
## class       : RasterLayer 
## dimensions  : 418, 1535, 641630  (nrow, ncol, ncell)
## resolution  : 0.008333333, 0.008333333  (x, y)
## extent      : -86.90809, -74.11642, 19.80837, 23.2917  (xmin, xmax, ymin, ymax)
## coord. ref. : NA 
## data source : in memory
## names       : layer.1 
## values      : 1, 1  (min, max)
## 
## 
## 
## Presence points (first ten only): 
## 
##  Longitude   Latitude
## ----------  ---------
##   -79.2527    22.2109
##   -78.7774    22.2241
##   -78.6189    22.2373
##   -78.1039    21.1809
##   -78.0247    21.1809
##   -77.9983    20.9301
##   -77.9719    21.7091
##   -77.9719    21.5507
##   -77.9323    21.6167
##   -77.9323    20.7320
## 
## 
## Background points (first ten only): 
## 
##  Longitude   Latitude
## ----------  ---------
##  -76.97892   20.79587
##  -77.94559   21.62920
##  -75.28726   20.54587
##  -76.41226   20.21254
##  -75.09559   20.12920
##  -77.97059   21.69587
##  -74.94559   20.33754
##  -77.95392   21.67087
##  -77.80392   21.47920
##  -74.97059   20.00420
## 
## 
## Species name:  allogus

Building an ENM

ENMTools contains functions to simplify the ENM construction process. Using enmtools.species objects and the correct modeling commands, we can build models very quickly. These commands are primarily wrappers to dismo model construction and projection functions, and at present are only available for GLM, Maxent, Domain, and Bioclim models. One of the nice bits about this setup is that it allows enmtools to automatically generate suitability maps, do model evaluation, and plot the marginal suitability of habitat for each variable separately.

GLM

GLMs require the user to supply a formula, an enmtools.species object, and some environmental data.

ahli.glm <- enmtools.glm(f = pres ~ layer.1 + layer.2 + layer.3 + layer.4, species = ahli, env = env, test.prop = 0.2)
## Adding environmental data to species ahli 
##  Processing presence points...
##  Processing background points...
allogus.glm <- enmtools.glm(pres ~ layer.1 + layer.2 + layer.3 + layer.4, allogus, env, test.prop = 0.2)
## Adding environmental data to species allogus 
##  Processing presence points...
##  Processing background points...
ahli.glm
## 
## 
## Formula:  presence ~ layer.1 + layer.2 + layer.3 + layer.4
## <environment: 0x7fe572a382e0>
## 
## 
## Data table (top ten lines): 
## 
##       Longitude   Latitude   layer.1   layer.2   layer.3   layer.4   presence
## ---  ----------  ---------  --------  --------  --------  --------  ---------
## 1      -80.0106    21.8744      2765      1235      1174       252          1
## 2      -79.9086    21.8095      2289      1732       957       231          1
## 3      -79.8065    21.7631      2158      1870       983       253          1
## 5      -79.8807    21.8374      2244      1828       945       249          1
## 6      -79.9550    21.8374      2250      1766       919       235          1
## 7      -80.3446    22.0136      2201      1822       978       277          1
## 10     -80.1591    21.9673      2984       965      1311       237          1
## 11     -80.1498    21.9858      3042       841      1371       221          1
## 12     -80.1220    21.9301      2898      1033      1231       242          1
## 13     -80.1776    21.9673      2914      1020      1256       237          1
## 
## 
## Model:  
## Call:
## glm(formula = f, family = "binomial", data = analysis.df[, -c(1, 
##     2)])
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -0.9020  -0.1700  -0.1090  -0.0688   3.2837  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)
## (Intercept) 29.569455  29.022738   1.019    0.308
## layer.1     -0.008556   0.007610  -1.124    0.261
## layer.2     -0.006039   0.008014  -0.754    0.451
## layer.3      0.007691   0.007496   1.026    0.305
## layer.4     -0.045642   0.030431  -1.500    0.134
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 130.29  on 1011  degrees of freedom
## Residual deviance: 113.62  on 1007  degrees of freedom
## AIC: 123.62
## 
## Number of Fisher Scoring iterations: 8
## 
## 
## 
## Model fit (training data):  class          : ModelEvaluation 
## n presences    : 12 
## n absences     : 1000 
## AUC            : 0.79675 
## cor            : 0.1275856 
## max TPR+TNR at : -4.174877 
## 
## 
## Proportion of data wittheld for model fitting:  0.2
## 
## Model fit (test data):  class          : ModelEvaluation 
## n presences    : 4 
## n absences     : 1000 
## AUC            : 0.53475 
## cor            : 0.007510712 
## max TPR+TNR at : -5.538576 
## 
## 
## Suitability:  
## class       : RasterLayer 
## dimensions  : 418, 1535, 641630  (nrow, ncol, ncell)
## resolution  : 0.008333333, 0.008333333  (x, y)
## extent      : -86.90809, -74.11642, 19.80837, 23.2917  (xmin, xmax, ymin, ymax)
## coord. ref. : NA 
## data source : in memory
## names       : layer 
## values      : 2.220446e-16, 0.9999339  (min, max)

To check out the marginal response functions, you only need to type

ahli.glm$response.plots
## $layer.1

## 
## $layer.2

## 
## $layer.3

## 
## $layer.4

Bioclim, Domain, and Maxent

The procedure for building Bioclim, Domain, and Maxent models is similar to the procedure for GLMs, with the exception that you do not need to pass a formula to the model function. Note that running Maxent models requires a bit of extra setup; see dismo documentation for details.

ahli.dm <- enmtools.dm(ahli, env, test.prop = 0.2)
ahli.bc <- enmtools.bc(ahli, env, test.prop = 0.2)
ahli.mx <- enmtools.maxent(ahli, env, test.prop = 0.2)

Metrics: breadth, correlation, and overlap

ENMTools provides a number of metrics for ENMs and for similarities between ENMs. These include measures of niche breadth, based on Levins(1968). An important caveat when interpreting these metrics is that they are driven to some (variable) extent by the availability of different combinations of environmental variables. As such they are more accurately interpreted as a measurment of the smoothness of the geographic distribution of suitability scores than as an estimate of the breadth of the fundamental niche; an orgamism with narrow fundamental niche breadth that nonetheless encompasses a set of environmental conditions that is quite common will have a high breadth when measured using ENMs, while having a low breadth in environment space.

raster.breadth(ahli.glm)
## $B1
## [1] 0.05737146
## 
## $B2
## [1] 0.8051085

ENMTools also provides metrics for measuring similarity between ENMs. These include Schoener’s D (Schoener 1968), I (Warren et al. 2008), and the Spearman rank correlation coefficient between two rasters. While D and I are commonly used in the ENM literature, they may tend to overestimate similarity between ENMs when many grid cells are of similar values (e.g., when two species prefer different habitat but the region contains a great deal of habitat that is unsuitable for both).

raster.overlap(ahli.glm, allogus.glm)
## $D
## [1] 0.2578193
## 
## $I
## [1] 0.5287324
## 
## $rank.cor
## [1] 0.4410981

A new feature of the R version of ENMTools is that you can now use these same metrics in the n-dimensional space of all combinations of environmental variables, instead of restricting your measures of model similarity to those sets of conditions that appear in the training region. This is done by repeatedly drawing Latin hypercube samples from the space of all possible combinations of environmental variables given the min and max of each variable within the training region. ENMTools continues to draw samples until subsequent iterations differ by less than a specified tolerance value. Lower tolerance values result in more precise estimates of overlap, but can take much longer to calculate.

env.overlap(ahli.glm, allogus.glm, env, tolerance = .001)
## $env.D
## [1] 0.1670917
## 
## $env.I
## [1] 0.3943894
## 
## $env.cor
## [1] 0.1011234

Hypothesis testing

Niche identity or equivalency test

In this example, we will run a niche identity (also called equivalency) test, as in Warren et al. 2008. This test takes the presence points for a pair of species and randomly reassigns them to each species, then builds ENMs for these randomized occurrences. By doing this many times, we can estimate the probability distribution for ENM overlap between species under the null hypothesis that the two species’ occurrences in the environment are effectively a random draw from the same underlying distribution. Note that niche evolution is only one of many reasons why two species’ realized environmental distributions might cause departures from this null hypothesis. See Warren et al. 2014 for details.

To run an identity test, we need to decide what type of models we will build, how many replicates we will run, and (in the case of GLM) a model formula to use for empirical models and the Monte Carlo replicates. The resulting object contains the replicate models, p values, and plots of the results. Typically idenity tests are run with at least 99 replicates, but we are using a smaller number here for the sake of execution time.

NOTE: In order for models to be comparable, both empirical and pseudoreplicate models for the identity test are conducted with pseudoabsence points pooled for the two species being compared.

id.glm <- identity.test(species.1 = ahli, species.2 = allogus, env = env, type = "glm", f = presence ~ layer.1 + layer.2 + layer.3 + layer.4, nreps = 4)
id.glm
## 
## 
##  
## 
## Identity test ahli vs. allogus
## 
## Identity test p-values:
##        D        I rank.cor    env.D    env.I  env.cor 
##      0.2      0.2      0.2      0.2      0.2      0.2 
## 
## 
## Replicates:
## 
## 
##                      D           I     rank.cor       env.D       env.I      env.cor
## ----------  ----------  ----------  -----------  ----------  ----------  -----------
## empirical    0.2332983   0.4815504   -0.4083273   0.0057679   0.0344405   -0.5400434
## rep 1        0.8311186   0.9798033    0.9501768   0.8342499   0.9757918    0.9655310
## rep 2        0.5766565   0.8539770    0.7676063   0.5724743   0.8184426    0.6329258
## rep 3        0.7520818   0.9507859    0.9077823   0.6917121   0.9121283    0.8428325
## rep 4        0.7891062   0.9619523    0.6493528   0.4274892   0.7388191    0.4165693

Background or similarity test

The background or similarity test compares the overlap seen between two species’ ENMs to the overlap expected by chance if one or both species was effectively choosing habitat at random from within their broad geographic range. The purpose of this test is to correct for the availability of habitat and ask whether the observed similarity between species or populations is significantly more (or less) than expected given the available set of environments in the regions in which they occur.

NOTE: In order for models to be comparable, both empirical and pseudoreplicate models for the background test are conducted with pseudoabsence points pooled for the two species being compared.

In Warren et al. 2008, we developed this test in the context of comparing one species’ actual occurrence to the random background occurrences of the other species. This is what we call an “asymmetric” test, and in our case we did the test in both directions with the idea that we might compare the results of A vs. B background to the results of B vs. A background. This may be informative in some cases, but many people have also found this asymmetry confusing (and indeed it is often difficult to interpret). For that reason, the background test here can be conducted against a null hypothesis that is generated from “asymmetric” (species.1 vs species.2 background) or “symmetric” (species.1 background vs. species.2 background) comparisons.

Here, for instance, is a Bioclim background test using the classical asymmetric approach:

bg.bc.asym <- background.test(species.1 = ahli, species.2 = allogus, env = env, type = "bc", nreps = 4, test.type = "asymmetric" )
bg.bc.asym
## 
## 
##  
## 
## Asymmetric background test ahli vs. allogus background
## 
## background test p-values:
##        D        I rank.cor    env.D    env.I  env.cor 
##      0.2      0.2      0.2      0.2      0.2      0.2 
## 
## 
## Replicates:
## 
## 
##                      D           I    rank.cor       env.D       env.I     env.cor
## ----------  ----------  ----------  ----------  ----------  ----------  ----------
## empirical    0.1328502   0.3177390   0.0706201   0.0212415   0.1060387   0.0816977
## rep 1        0.1493188   0.3363231   0.1443022   0.0451796   0.1644102   0.1051280
## rep 2        0.1558439   0.3468975   0.1567561   0.0509005   0.1620024   0.0880522
## rep 3        0.1559461   0.3560176   0.1705711   0.0322000   0.1545519   0.1073208
## rep 4        0.1690062   0.3709514   0.2274808   0.0915837   0.2373656   0.2041919

And here is a Domain background test using the symmetric approach:

bg.dm.sym <- background.test(species.1 = ahli, species.2 = allogus, env = env, type = "dm", nreps = 4, test.type = "symmetric" )
bg.dm.sym
## 
## 
##  
## 
## Symmetric background test ahli background vs. allogus background
## 
## background test p-values:
##        D        I rank.cor    env.D    env.I  env.cor 
##      0.2      0.2      0.2      0.2      0.2      0.2 
## 
## 
## Replicates:
## 
## 
##                      D           I    rank.cor       env.D       env.I     env.cor
## ----------  ----------  ----------  ----------  ----------  ----------  ----------
## empirical    0.4929334   0.7052122   0.2916150   0.1058820   0.3091703   0.2238400
## rep 1        0.9280175   0.9897200   0.5953461   0.2214193   0.4564135   0.4956323
## rep 2        0.9725554   0.9989085   0.9475557   0.7790050   0.9188828   0.8965740
## rep 3        0.9630957   0.9983155   0.7097176   0.6261012   0.8160475   0.7997361
## rep 4        0.8721724   0.9652981   0.6812774   0.2623149   0.5002702   0.5047197

Rangebreak tests

ENMTools also allows you to perform linear, blob, and ribbon rangebreak tests as developed in Glor and Warren 2011. The linear and blob tests are two versions of a test that permit one to ask whether the geographic regions occupied by two species are more environmentally different than expected by chance. The ribbon test, meanwhile, is designed to test whether the ranges of two species are divided by a region that is relatively unsuitable to one or both forms.

For the linear and blob tests, you call them very much like you would the identity and background tests. Here’s a linear one using GLM models:

rbl.glm <- rangebreak.linear(ahli, allogus, env, type = "bc", f = pres ~ layer.1 + layer.2 + layer.3 + layer.4, nreps = 4)
## 
## Building empirical models...
## 
## Building replicate models...
## 
## Replicate 1 ...
## 
## Replicate 2 ...
## 
## Replicate 3 ...
## 
## Replicate 4 ...
rbl.glm
## 
## 
##  
## 
## Linear rangebreak test ahli vs. allogus
## 
## rangebreak test p-values:
##        D        I rank.cor    env.D    env.I  env.cor 
##      0.8      0.8      0.8      0.2      0.2      0.4 
## 
## 
## Replicates:
## 
## 
##                      D           I     rank.cor       env.D       env.I     env.cor
## ----------  ----------  ----------  -----------  ----------  ----------  ----------
## empirical    0.1328502   0.3177390    0.0706201   0.0201829   0.1117191   0.0896411
## rep 1        0.0327940   0.1544608   -0.0172882   0.2018422   0.2911232   0.2464290
## rep 2        0.0421010   0.1800671    0.0373002   0.0246462   0.1201778   0.0868383
## rep 3        0.2436563   0.4464256    0.2104093   0.0280533   0.1274017   0.1024382
## rep 4        0.0327940   0.1544608   -0.0172882   0.2199041   0.3090015   0.2546620

And here’s a blob test using Bioclim:

rbb.bc <- rangebreak.blob(ahli, allogus, env, type = "bc", nreps = 4)
## 
## Building empirical models...
## 
## Building replicate models...
## 
## Replicate 1 ...
## 
## Replicate 2 ...
## 
## Replicate 3 ...
## 
## Replicate 4 ...
rbb.bc
## 
## 
##  
## 
## blob rangebreak test ahli vs. allogus
## 
## rangebreak test p-values:
##        D        I rank.cor    env.D    env.I  env.cor 
##      1.0      1.0      1.0      0.2      0.2      0.2 
## 
## 
## Replicates:
## 
## 
##                      D           I     rank.cor       env.D       env.I     env.cor
## ----------  ----------  ----------  -----------  ----------  ----------  ----------
## empirical    0.1328502   0.3177390    0.0706201   0.0214385   0.1129767   0.0876133
## rep 1        0.1328502   0.3177390    0.0706201   0.0242327   0.1264412   0.0981463
## rep 2        0.0327940   0.1544608   -0.0172882   0.2133957   0.3038321   0.2547176
## rep 3        0.0120159   0.0728890   -0.1245816   0.0972116   0.1454808   0.1242970
## rep 4        0.1328502   0.3177390    0.0706201   0.0218022   0.1183835   0.0946470

If you want to access the individual replicates (for instance to see how your ranges are being split up), you can find them in the list named “replicate.models” inside your rangebreak test object.

rbl.glm$replicate.models$ahli.rep.1
## 
## 
## Data table (top ten lines): 
## 
##       Longitude   Latitude
## ---  ----------  ---------
## 81     -74.1691    20.2170
## 80     -74.2351    20.2302
## 76     -74.2747    20.1114
## 78     -74.2483    20.2434
## 77     -74.2628    20.2134
## 79     -74.2483    20.2963
## 75     -74.3143    20.2434
## 74     -74.3803    20.1378
## 72     -74.4595    20.1906
## 73     -74.4331    20.2963
## 
## 
## Model:  class    : Bioclim 
## 
## variables: layer.1 layer.2 layer.3 layer.4 
## 
## 
## presence points: 16 
##    layer.1 layer.2 layer.3 layer.4
## 1     1608    1722     972     445
## 2     1932    1423     998     485
## 3     1972    1243    1112     422
## 4     1933    1431     954     485
## 5     1987    1336    1027     474
## 6     1935    1503     923     521
## 7     2064    1330     901     528
## 8     2060    1291     918     503
## 9     2190    1196     994     502
## 10    2690    1120     385     775
##   (... ...  ...)
## 
## 
## 
## Model fit (training data):  class          : ModelEvaluation 
## n presences    : 16 
## n absences     : 2000 
## AUC            : 0.9643594 
## cor            : 0.27485 
## max TPR+TNR at : 0.0624 
## 
## 
## Proportion of data wittheld for model fitting:  0
## 
## Model fit (test data):  [1] NA
## 
## 
## Suitability:  
## class       : RasterLayer 
## dimensions  : 418, 1535, 641630  (nrow, ncol, ncell)
## resolution  : 0.008333333, 0.008333333  (x, y)
## extent      : -86.90809, -74.11642, 19.80837, 23.2917  (xmin, xmax, ymin, ymax)
## coord. ref. : NA 
## data source : in memory
## names       : layer 
## values      : 0, 0.9375  (min, max)

rbl.glm$replicate.models$allogus.rep.1
## 
## 
## Data table (top ten lines): 
## 
##       Longitude   Latitude
## ---  ----------  ---------
## 65     -74.8029    20.3359
## 64     -74.8161    20.5867
## 63     -74.8293    20.5471
## 60     -74.9745    20.1114
## 56     -75.0537    20.0454
## 57     -75.0273    20.1510
## 62     -74.9349    20.5339
## 61     -74.9481    20.6264
## 55     -75.1198    20.1114
## 59     -74.9877    20.6528
## 
## 
## Model:  class    : Bioclim 
## 
## variables: layer.1 layer.2 layer.3 layer.4 
## 
## 
## presence points: 65 
##    layer.1 layer.2 layer.3 layer.4
## 1     2268    1102    1199     419
## 2     2558    1292     660     706
## 3     2418    1234     903     604
## 4     2018    1467    1012     355
## 5     1812    1709    1025     325
## 6     2022    1563     972     330
## 7     2312    1107    1243     427
## 8     2345    1410     738     656
## 9     1748    1782     957     332
## 10    2328    1492     779     664
##   (... ...  ...)
## 
## 
## 
## Model fit (training data):  class          : ModelEvaluation 
## n presences    : 65 
## n absences     : 3000 
## AUC            : 0.5028462 
## cor            : 0.006263284 
## max TPR+TNR at : 0.3537462 
## 
## 
## Proportion of data wittheld for model fitting:  0
## 
## Model fit (test data):  [1] NA
## 
## 
## Suitability:  
## class       : RasterLayer 
## dimensions  : 418, 1535, 641630  (nrow, ncol, ncell)
## resolution  : 0.008333333, 0.008333333  (x, y)
## extent      : -86.90809, -74.11642, 19.80837, 23.2917  (xmin, xmax, ymin, ymax)
## coord. ref. : NA 
## data source : in memory
## names       : layer 
## values      : 0, 0.9538462  (min, max)

For the ribbon rangebreak test, you will need one extra thing; a third enmtools.species object representing the occurrence points (for one or both species) that fall within the ribbon of putatively unsuitable habitat. In the case of these two anoles we don’t have such a ribbon, so we’ll just simulate one based on some random points.

ribbon <- enmtools.species(species.name = "ribbon")
ribbon$presence.points <- data.frame(Longitude = runif(n = 10, min = -79, max = -78.5),
                                      Latitude = runif(n = 10, min = 21.7, max = 22.1))
plot(env[[1]])
points(ribbon$presence.points, pch = 16)

ribbon$range <- background.raster.buffer(ribbon$presence.points, 20000, mask = env)
ribbon
## 
## 
## Range raster: 
## class       : RasterLayer 
## dimensions  : 418, 1535, 641630  (nrow, ncol, ncell)
## resolution  : 0.008333333, 0.008333333  (x, y)
## extent      : -86.90809, -74.11642, 19.80837, 23.2917  (xmin, xmax, ymin, ymax)
## coord. ref. : NA 
## data source : in memory
## names       : layer.1 
## values      : 1, 1  (min, max)
## 
## 
## 
## Presence points (first ten only): 
## 
##  Longitude   Latitude
## ----------  ---------
##  -78.60287   21.88695
##  -78.71646   21.90496
##  -78.99808   21.76101
##  -78.79737   21.99928
##  -78.62910   21.91068
##  -78.81836   21.76227
##  -78.66197   21.95354
##  -78.54537   21.92119
##  -78.68236   21.77295
##  -78.86937   21.89114
## 
## 
## Background points not defined.
## 
## Species name:  ribbon

Now we’ll run a ribbon rangebreak test using Domain models. We also need to tell it the width of the ribbons to generate for the replicates. The units for the width argument are the same units that the presence points are in; e.g., if the points are in decimal degrees you should supply the width of the barrier in decimal degrees.

rbr.dm <- rangebreak.ribbon(ahli, allogus, ribbon, env, type = "dm", width = 0.5, nreps = 4)
## 
## 
## No background points provided, drawing background from range raster.
## Warning in couldBeLonLat(mask): CRS is NA. Assuming it is longitude/
## latitude
## 
## Building empirical models...
## 
## Building replicate models...
## 
## Replicate 1 ...
##         D         I  rank.cor     env.D     env.I   env.cor 
## 0.8628956 0.9814648 0.5672228 0.5893370 0.7937888 0.7058197 
##          D          I   rank.cor      env.D      env.I    env.cor 
## 0.64319905 0.82552216 0.34364846 0.04718682 0.20048449 0.17175669 
##          D          I   rank.cor      env.D      env.I    env.cor 
## 0.62465836 0.81797828 0.57350104 0.02878751 0.15746448 0.16138130 
##         D         I  rank.cor     env.D     env.I   env.cor 
## 0.6243837 0.8174033 0.5253706 0.0286071 0.1578770 0.1720737 
## 
## Replicate 2 ...
##         D         I  rank.cor     env.D     env.I   env.cor 
## 0.7174896 0.8971607 0.1971462 0.1541998 0.3719659 0.3602245 
##         D         I  rank.cor     env.D     env.I   env.cor 
## 0.6249317 0.7957796 0.3499769 0.1838045 0.3943525 0.3386606 
##          D          I   rank.cor      env.D      env.I    env.cor 
## 0.62342181 0.81723814 0.54828117 0.02947267 0.15872530 0.16097014 
##          D          I   rank.cor      env.D      env.I    env.cor 
## 0.62438368 0.81740330 0.52537063 0.02747077 0.15327171 0.16961920 
## 
## Replicate 3 ...
##          D          I   rank.cor      env.D      env.I    env.cor 
##  0.6695145  0.8916104 -0.3781441  0.3987313  0.5645421  0.2663970 
##           D           I    rank.cor       env.D       env.I     env.cor 
## 0.662167400 0.864812822 0.008908077 0.061815506 0.187516779 0.097045625 
##         D         I  rank.cor     env.D     env.I   env.cor 
## 0.8462745 0.9615444 0.2865494 0.2088810 0.4411895 0.3727709 
##           D           I    rank.cor       env.D       env.I     env.cor 
##  0.81758593  0.94955355 -0.12222333  0.08846976  0.27909765  0.29250188 
## 
## Replicate 4 ...
##         D         I  rank.cor     env.D     env.I   env.cor 
## 0.8028599 0.9348436 0.1859907 0.2214075 0.4567968 0.3395729 
##         D         I  rank.cor     env.D     env.I   env.cor 
## 0.1280802 0.3377350 0.2543835        NA        NA        NA 
##            D            I     rank.cor        env.D        env.I 
## 0.1001650934 0.2984728070 0.2230247078 0.0005879003 0.0241333659 
##      env.cor 
## 0.0235833449 
##         D         I  rank.cor     env.D     env.I   env.cor 
## 0.0992469 0.2969925 0.2439318        NA        NA        NA 
## 
## Replicate 4 ...
##         D         I  rank.cor     env.D     env.I   env.cor 
## 0.6504495 0.8285161 0.2881258 0.1741126 0.4011679 0.3066944 
##          D          I   rank.cor      env.D      env.I    env.cor 
## 0.10332548 0.30067444 0.21357543 0.01092841 0.09444309 0.07429082 
##           D           I    rank.cor       env.D       env.I     env.cor 
## 0.070466389 0.251387073 0.353031266 0.001539699 0.034347798 0.037332173 
##           D           I    rank.cor       env.D       env.I     env.cor 
## 0.068829043 0.248119967 0.337298488 0.001243233 0.031253891 0.035201998
rbr.dm
## 
## 
##  
## 
## ribbon rangebreak test ahli vs. allogus
## 
## rangebreak test p-values...
## 
## Species 1 vs. Species 2:
##        D        I rank.cor    env.D    env.I  env.cor 
##      0.2      0.2      0.8      0.2      0.2      0.2 
## 
## Species 1 vs. Ribbon:
##        D        I rank.cor    env.D    env.I  env.cor 
##      0.4      0.4      0.4       NA       NA       NA 
## 
## Species 2 vs. Ribbon:
##        D        I rank.cor    env.D    env.I  env.cor 
##      0.4      0.4      0.2       NA       NA       NA 
## 
## Outside vs. Ribbon:
##        D        I rank.cor    env.D    env.I  env.cor 
##      0.4      0.4      0.2       NA       NA       NA 
## 
## 
## Replicates:
## 
## Species 1 vs. Species 2:
##                   D         I   rank.cor     env.D     env.I   env.cor
## empirical 0.4929334 0.7052122  0.2916150 0.1053488 0.3076897 0.2236458
## rep 1     0.8628956 0.9814648  0.5672228 0.5893370 0.7937888 0.7058197
## rep 2     0.7174896 0.8971607  0.1971462 0.1541998 0.3719659 0.3602245
## rep 3     0.6695145 0.8916104 -0.3781441 0.3987313 0.5645421 0.2663970
## rep 4     0.6504495 0.8285161  0.2881258 0.1741126 0.4011679 0.3066944
## 
## Species 1 vs. Ribbon:
##                   D         I    rank.cor      env.D      env.I    env.cor
## empirical 0.1525462 0.3226316 0.151298990         NA         NA         NA
## rep 1     0.6431990 0.8255222 0.343648460 0.04718682 0.20048449 0.17175669
## rep 2     0.6249317 0.7957796 0.349976924 0.18380452 0.39435251 0.33866062
## rep 3     0.6621674 0.8648128 0.008908077 0.06181551 0.18751678 0.09704563
## rep 4     0.1033255 0.3006744 0.213575428 0.01092841 0.09444309 0.07429082
## 
## Species 2 vs. Ribbon:
##                    D         I   rank.cor       env.D     env.I    env.cor
## empirical 0.10700943 0.3081626 -0.2382355          NA        NA         NA
## rep 1     0.62465836 0.8179783  0.5735010 0.028787514 0.1574645 0.16138130
## rep 2     0.62342181 0.8172381  0.5482812 0.029472672 0.1587253 0.16097014
## rep 3     0.84627450 0.9615444  0.2865494 0.208881013 0.4411895 0.37277086
## rep 4     0.07046639 0.2513871  0.3530313 0.001539699 0.0343478 0.03733217
## 
## Outside vs. Ribbon:
##                    D         I   rank.cor       env.D      env.I   env.cor
## empirical 0.10763581 0.3091680 -0.2492925          NA         NA        NA
## rep 1     0.62438368 0.8174033  0.5253706 0.028607101 0.15787698 0.1720737
## rep 2     0.62438368 0.8174033  0.5253706 0.027470775 0.15327171 0.1696192
## rep 3     0.81758593 0.9495536 -0.1222233 0.088469764 0.27909765 0.2925019
## rep 4     0.06882904 0.2481200  0.3372985 0.001243233 0.03125389 0.0352020

## Warning: Removed 1 rows containing missing values (geom_vline).
## Warning: Removed 1 rows containing missing values (geom_vline).

## Warning: Removed 1 rows containing missing values (geom_vline).

## Warning: Removed 1 rows containing missing values (geom_vline).

## Warning: Removed 1 rows containing missing values (geom_vline).

## Warning: Removed 1 rows containing missing values (geom_vline).

## Warning: Removed 1 rows containing missing values (geom_vline).

## Warning: Removed 1 rows containing missing values (geom_vline).

## Warning: Removed 1 rows containing missing values (geom_vline).

Note that the output table here has slope, intercept, and intercept offset.

rbr.dm$lines.df
##         slope   intercept    offset
## 1   0.1679650    33.89303 0.2535020
## 2   0.1182077    30.05965 0.2517406
## 3  -0.6219546   -26.72845 0.2944091
## 4 -17.6612745 -1347.16071 4.4223906

The intercept denotes the intercept corresponding to the CENTER of the ribbon. To get the lines denoting the edges of the ribbons (for example if you want to plot the ribbons on a map), you add and substract the offset. In other words, the top edge of the ribbon is given by y = (slope * x) + intercept + offset, while the bottom edge is given by y = (slope * x) + intercept - offset.

Literature cited

Levins, R. 1968. Evolution In Changing Environments. Monographs in Population Biology, volume 2. Princeton University Press, Princeton, New Jersey, USA.

Schoener, T. W. 1968. Anolis lizards of Bimini: resource partitioning in a complex fauna. Ecology 49:704- 726.

Warren, D.L., R.E. Glor, and M. Turelli. 2008. Environmental niche identity versus conservatism: quantitative approaches to niche evolution. Evolution 62:2868-2883. doi: 10.1111/j.1558-5646.2008.00482.x

Warren, D.L., M. Cardillo, D.F. Rosauer, and D.I. Bolnick. 2014. Mistaking geography for biology: inferring processes from species distributions. Trends in Ecology and Evolution 29 (10), 572-580. doi: 10.1016/j.tree.2014.08.003